package com.wanshi.servlet;

import com.wanshi.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/active")
public class active extends HttpServlet {
    UserService userService = new UserService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1 获取statecode

        //2 激活

        //3 页面跳转

        //1 获取激活码
        String statecode = request.getParameter("statecode");

        //2 激活
        userService.updateUserByCode(statecode);

        //3 重定向到登录界面
        response.getWriter().write("恭喜您激活成功,3秒后跳转到登录界面");
        response.setHeader("Refresh", "3;url="+request.getContextPath()+"/login.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}

